'use strict';

angular.module('metalabPartnerApp').directive('metaFormMaxThan', function () {
    return {
        restrict: 'A',
        require: 'ngModel',
        scope: {
            bindData: '=metaFormMaxThan'
        },
        link: function (scope, elem, attrs, ngModel) {
            ngModel.$validators.metaFormMaxThan = function (modalValue) {
                if (scope.bindData !== undefined) {
                    return modalValue >= scope.bindData;
                } else {
                    return false;
                }
            };

            scope.$watch('bindData', function () {
                ngModel.$validate();
            });
        }
    };
});
